<template>
  <view v-if="!hasService" class="noService">
      <image style="width: 100vw;" src="https://pics.leshiguang.com/vpage/2024/01/26/28016078292e4466b5efe72efc9e0de9.jpeg" mode="widthFix">
        
      </image>
      <view class="button" @click="openService"><image style="width: 20px; height: 20px; margin-right: 4px;" src="https://pics.leshiguang.com/vpage/2024/01/19/ac945ccc292b4c1d98f0f5526807b1a8.png"></image> 开启服务</view>
  </view>
  <view v-else class="service">
    <view class="head">
      <view class="left">服务项目</view>
      <view class="right" @click="onKnowMore">
        了解更多
        <image style="width: 16px; height: 16px;" src="https://pics.leshiguang.com/vpage/2024/01/02/6fd21b894b2d489b9b7fafd55a5a59ef.png">
        </image>
      </view>
    </view>

    <cmenu :healthStatus="healthStatus"/>

    <view class="score" v-if="result && result.healthLevel">
      <view class="left">
        <view class="top">
          <view style="margin-right: 6px;">
          {{ result.healthLevel }}
          </view>
          <score :score="result.starNum" ></score>
        </view>
        <view class="bottom">{{ `您的健康水平超过了${result.numberSurpluses}%的人` }}</view>
      </view>
      <view class="right" @click="goDetail">详情</view>
    </view>

    <u-popup v-model="showNote" mode="center" :height="'80%'" border-radius="20" :mask="true" :mask-custom-style="{background: 'rgba(0, 0, 0, 0.5)'}">
      <view class="popup" @click="showNote = false">
        <image class="popup-image" src="https://pics.leshiguang.com/vpage/2024/01/26/28016078292e4466b5efe72efc9e0de9.jpeg" mode="widthFix" :lazy-load="false" binderror="" bindload="">
        </image>
        <!-- <view class="popup-button"
          @click="showNote = false">我知道了</view> -->
      </view>
    </u-popup>
  </view>
</template>

<script>

import uMask from "uview-ui/components/u-mask/u-mask.vue";
import uPopup from "uview-ui/components/u-popup/u-popup.vue";
import cmenu from "./cmenu.vue";
import score from './score.vue'
export default {
  components: {uPopup, uMask, score, cmenu},
  props: {
    healthStatus: {
      Type: Array,
      default: () => [],
    },
    service: {
      type: Number,
    },
    result: {
      type: Object,
    }
  },
  emits: ['applyService'],
  data() {
    return {
      showNote: false,
      hasKind: true,
    };
  },
  onShow() {
    this.getHealthService();
  },
  computed: {
    hasService() {
      return  !!this.service;
    }
  },
  methods: {
    loadData() {

    },
    onBannerClick() {

    },

    onKnowMore() {
      this.showNote = true;
    },
    openService() {
      this.$emit('applyService');
    },
    goDetail() {
      this.$basejs.globaltoken();
      if (!global.token) return;

      if (this.result?.starNum) {
        uni.navigateTo({
          url: '/pages/subpackage/home/HealthReport/HealthReport?userAnsId=' + this.result.userAnsId
        })
      } else {
        uni.navigateTo({
          url: '/pages/subpackage/home/oneAccess/evaluating'
        })
      }
    },
  },
};
</script>
<style lang="scss" scoped>

.noService {
  display: flex;
  margin-bottom: 0;
  align-items: center;
  flex-direction: column;
  width: 100%;
  min-height: 100vh;
  .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 275px;
    padding: 12px;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    border-radius: 25px;
    background-color: #057691;
    color: white;
    bottom: 10px;
    box-shadow: 0px 2px 24px rgba(34, 34, 34, 0.04);
    margin-top: -60px;
    position: -webkit-sticky;
    position: sticky;
  }
}
.service {
  margin: 0 12px 12px 12px;
  background-color: white;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0px 2px 24px rgba(34, 34, 34, 0.04);
  .head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    .left {
      font-size: 18px;
      font-weight: bold;
      color: #222;
    }
    .right {
      display: inline-flex;
      align-items: center;
      flex: none;
      font-size: 13px;
      color: rgba(34, 34, 34, 0.4);
    }
  }
}

.score {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(5, 118, 145, 0.16) 0%, rgba(5, 118, 145, 0.10) 100%) no-repeat;
  .left {
    .top {
      display: flex;
      align-items: baseline;
      margin-bottom: 0px;
      font-size: 36px;
      color: #222;
    }
    .bottom {
      font-size: 12px;
      color: #222;
    }
  }

  .right {
    flex: none;
    font-size: 13px;
    font-weight: bold;
    padding: 5px 17px;
    border-radius: 14px;
    background-color: #057691;
    color: white;
    transform: rotate(30);
  }
  
}

.popup {
  background-color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0px 2px 24px 0px rgba(0,0,0,0.12);
  .popup-image {
    margin-bottom: 4px;
    width: 350px;
  }

  .popup-button {
    width: 275px;
    padding: 12px;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    border-radius: 25px;
    background-color: #057691;
    color: white;
  }
}



</style>
